<!DOCTYPE html>
<!-- saved from url=(0071)http://www.uphsh.com/wap/ef73d9dc381d412f964b99e521c270a6/invoice/addUI -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--<base href="http://www.uphsh.com:80/">--><base href=".">
<title>新户注册</title>


<meta name="description" content="新户注册">
<meta name="keywords" content="新户注册">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">

	<link type="text/css" href="../../resource/xhzc/wapcommon.css" rel="stylesheet">

  <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
  <link type="text/css" rel="stylesheet" href="../../template/css/com/com.css"/>
  <link type="text/css" rel="stylesheet" href="../../template/css/list/style.css"/>
  <link rel="stylesheet" href="../../resource/weuimin.css"/>
  <link rel="stylesheet" href="../../resource/example.css"/>

	<script src="../../resource/jquery1.js"></script>
	<script type="text/javascript" src="../../resource/common.js"></script>
	<script src="../../resource/tjxxfiles/jquery180min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../resource/tjxxfiles/wapcommon.js"></script>
    <script src="../../script/api.js"></script>
    <script type="text/javascript" src="../../script/aes.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script type="text/javascript" src="../../script/modeecb.js"></script>
    <script type="text/javascript" src="../../script/tmd5.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>

		<script type="text/javascript" src="../../resource/xhzc/my.js"></script>
	<style>

  #pxui-form .shxx{
    border: 1px solid #f7bfbf;
    padding: 10px;
    width:93%;
		font-size: 17px;
  }
  #pxui-form p{padding-left:3%;width: 95%;}
  #dzlist .addr_checkbox{float:left;margin:8px 5px 0 0;}
  #kpxx .kpxz,#kpxx .sfkp{float:left;margin:6px 5px 0 0;}
  .dzsel{width:31%;margin:0 1% 10px 0;padding:6px;border:1px solid #f7bfbf;}
  .pxui-form-info{padding:0px;}
  .page-title{margin-bottom:10px;}
  .pxui-area .pxui-form-info {margin: 5px 10px;}
  .noscroll,
.noscroll body {
    overflow: hidden;
}
.noscroll body {
    position: relative;
}
  #bg{position: absolute;  top: 0%;  left: 0%;  width: 100%;background-color: black;  z-index:1001;  -moz-opacity: 0.7;  opacity:.70;  filter: alpha(opacity=70);}

	</style>
</head>
<body>
  <div style="display:none" id="bg"></div>
  <header id="statusBar">
	<div class="header">
        <div class="return">
					<a tapmode="" style="color:#fff" onclick="api.closeWin();">
							<span>返回</span>
					</a>
        </div>
        <div class="tittle">
    		邮寄信息
        </div>
    </div>
    </header>
    <div id="contant" style="height: 563px;">
      <div class="com-content-area" id="js-com-content-area" style="padding:0px 0 10px 0;">
  <!-- 			<div class="pxui-tab pxui-tab-nav pxui-tab-no-top">
  				<a href="main.html"><i></i>首 页<span></span></a>
  				<a href="history.html"><i></i>历史订单<span></span></a>
  				<a href="bill.html" class="selected"><i></i>购物框<span></span></a>
  			</div> -->
  			<div class="page-role cart-page cart-index-page" >
  				<form id="js-form" action="/order/trolly" method="post">
  					<div class="pxui-area goodlist">
  						<!--div style="text-align:center;padding: 50px 0;font-size: 16px;">您当前购物车空荡荡的，赶快去添加吧！
  						<br/>
  						<a href="../../default.htm">返回首页</a>
  						</div-->
  						<div id="pxui-form" class="pxui-form-info" >
  							<b>邮寄信息</b>
								<div id="dzlist">
									数据加载中...
								</div>
  							<p>
									<b>新增地址</b>：
									<input id="box0" type="checkbox" class="addr_checkbox" style="float:left;margin:8px 5px 0 0;" onclick="selectAddr(0)"/><br/>
  								<label>收件人姓名 (必填)：</label><input id="sh_mc"  class="shxx" value=""/><br/>
  								<label>联系电话 (必填)：</label><input id="sh_dh" class="shxx" value=""/><br/>
  								<label>详细地址(必填) ：</label><br/>
  								<select class="dzsel" id="address_sheng" onchange="loadShi()">

  								</select>
  								<select class="dzsel" id="address_shi" onchange="dqdm()">

  								</select>
  								<select class="dzsel" id="address_qx">

  								</select>
  								<input id="sh_dz" class="shxx" value=""/>
  							</p>
  						 </div>
  					</div>
  					<div class="pxui-area goodlist" style="margin-top:12px;">

  						<div id="total_dv" style="font-weight:bold;width:98%;float:left;text-align:right;">
  							<label id="toll">总计：<label class="pxui-color-red" id="zje">NaN</label> </label><input
  								type="button" id="pay_button" class="pxui-light-button addtocart" value="支  付" onclick="payMethod()" tapmode="presshover"/>
  						</div>
  					</div>
  				</form>
  			</div>

        <div id="loadingToast" style="display:none;">
 		        <div class="weui-mask_transparent"></div>
 		        <div class="weui-toast">
 		            <i class="weui-loading weui-icon_toast"></i>
 		            <p class="weui-toast__content">数据提交中...</p>
 		        </div>
 			  </div>
   			<div id="msgToast" style="display:none;">
   		        <div class="weui-mask_transparent"></div>
   		        <div class="weui-toast">
   		            <i class="weui-loading weui-icon_toast"></i>
   		            <p class="weui-toast__content">地址数据获取中...</p>
   		        </div>
   			</div>

<div class="copyright">四川航天信息有限公司<br>客户热线：<a href="tel:95113" style="color: gray;">95113</a></div>
</div>

<script>
</script>

<script type="text/javascript">
    var total;//已存储的总价格
    var pay;//支付方式
    var data;//加载省市数据
    var taxcode="";
    var rid="";
    var zcdz="";//注册地址
    var lxr="";//联系人
    var lxdh="";//联系电话
		var orderid="";//订单id
		var allspmc;//商品名称
		var seli=0;
		var dzObj = null;
		var _openid = "";

    apiready=function(){
          if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
		  }
          $api.fixStatusBar( $api.dom('header') );
          /*api.addEventListener({
          name: 'keyback'
          }, function(ret, err) {
              funcGoto();
              api.closeFrame({
                name:"xhzf"
          	  });
          });*/
					api.parseTapmode();
          total = api.pageParam.total;
          pay   = api.pageParam.pay;
          taxcode= api.pageParam.taxcode;
					orderid= api.pageParam.orderid;
					allspmc= api.pageParam.allspmc;
					_openid = $api.getStorage('openid');
					rid=api.pageParam.rid;
					zcdz=api.pageParam.zcdz;
					lxr  = api.pageParam.lxr;
		  			lxdh  = api.pageParam.lxdh;	  
					
          if(pay=='3'){
              $("#toll").hide();
							$("#dzlist").hide();
							document.getElementById("box0").checked =true;
              document.getElementById("pay_button").value="保  存";
          }else{
          	  if(boolValue(orderid)){
				addr(orderid);
			  }else{
			  	$("#total_dv").hide();
			  }
              $("#zje").html("￥"+parseFloat(total));
          }

					//if(boolValue(orderid)){
					//	addr(orderid);
					//}else{
						//赋值注册
						$("#sh_dz").val(zcdz);
						$("#sh_mc").val(lxr);
						$("#sh_dh").val(lxdh);
					//}
          loadSheng();
    }

    function loadSheng(){

   		$("#msgToast").show();
   		var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
          data = ret.json;
		    	var html = "";
		    	for(var i=0;i<data.length;i++){
		    		if(data[i].mc.indexOf("四川") == 0){
		    			html += "<option value=\"" + data[i].dm + "\" selected=\"selected\">"+ data[i].mc + "</option>"
		    		}else{
		    			html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>";
		    		}
		    	}
		    	$("#address_sheng").html(html);
		    	$("#msgToast").hide();
		    	/*if(seli == 0){
		    		//判断是省内还是省外
			    	var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
			    	if(num == 0){
			    		$("#zje").html("￥" + parseInt(allPrice));
			    	}else{
			    		$("#zje").html("￥" + (parseInt(allPrice) + 12.00));
			    	}
		    	}*/
		    	loadShi();
        }
	    var content = {"dqdm":"100000","openid":"","wlfs":1};
	    apiAjax(JSON.stringify(content),url.dqurl,callback);
   	}



    function dqdm(){
      $("#msgToast").show();
      var callback = function(ret, err){
            //console.log(JSON.stringify(ret));
             $("#msgToast").hide();
        var data = ret.json;
        var html = "";
        for(var i=0;i<data.length;i++){
          html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>"
        }
        $("#address_qx").html(html);
        }
      var content = {"dqdm":$("#address_shi").val(),"openid":"","wlfs":1};
      apiAjax(JSON.stringify(content),url.dqurl,callback);
    }

    function loadShi(){
      var sdm = $("#address_sheng").val();
      /*for(var i=0;i<data.length;i++){
        if(data[i].dm==sdm){
            if(data[i].mc.indexOf('四川')!=-1){
              $("#zje").html("￥"+parseFloat(total));
            }else{
              $("#zje").html("￥"+(parseFloat(total)+12.00 ));
            }
        }
      }*/

      $("#msgToast").show();
      var callback = function(ret, err){
              //console.log(JSON.stringify(ret));
              var data = ret.json;

            var html = "";
            for(var i=0;i<data.length;i++){
              html += "<option value=\"" + data[i].dm + "\">"+ data[i].mc + "</option>"
            }
            $("#address_shi").html(html);
            $("#msgToast").hide();
            dqdm();
          }
      var content = {"dqdm":sdm,"openid":"","wlfs":1};
        apiAjax(JSON.stringify(content),url.dqurl,callback);
    }

    function payMethod(){
         var amc1 ="";// $("#sh_mc").val();
         var adh1 ="";// $("#sh_dh").val();
         var adz1 ="";// $("#sh_dz").val();

				 if(seli ==0){
					 		amc1 = $("#sh_mc").val();
							adh1 = $("#sh_dh").val();
							adz1 = $("#sh_dz").val();

							if(amc1 =="" || adh1 =="" || adz1 ==""){
		            $("#loadingToast").hide();
		            alert("请完善必填项！");
		            return;
		          }

		         if(amc1.length > 10){
		           $("#loadingToast").hide();
		           alert("收货人姓名过长！");
		           return;
		         }
		         if(adh1.length > 12){
		           $("#loadingToast").hide();
		           alert("联系电话过长！");
		           return;
		         }
		         if(adz1.length > 100){
		           $("#loadingToast").hide();
		           alert("详细地址过长！");
		           return;
		         }

						 adz1 = $("#address_sheng").find("option:selected").text() + $("#address_shi").find("option:selected").text() + "," + $("#address_qx").find("option:selected").text()  + "," + adz1;
		         //var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
				 }else{
					 amc1 = dzObj[seli-1].mc;
					 adh1 = dzObj[seli-1].dh;
					 adz1 = dzObj[seli-1].dz;
				 }

				 var jp = $api.getStorage("dl_phone");
				 if (!boolValue(jp)) {
					 api.alert({
						 msg: '请登录'
					 }, function(ret, err) {
						 api.openWin({
							 name: '跳转登陆',
							 url: '../login.html'
						 });
					 });
				 } else {
	           $("#loadingToast").show();
	             var callback = function(ret, err){
	               $("#loadingToast").hide();
	                   if (ret) {
	                     if(ret.success){
												 if(pay=='3'){//刷卡支付  保存邮寄信息
												 	api.alert({
									 			        msg: '保存成功！',
									 			        buttons: ['确定']
													});
													 api.closeToWin({
														 name: 'root'
													});
												}else{//在线支付
													var width = document.documentElement.clientWidth;
													var height = document.documentElement.clientHeight;
													var hh = document.body.scrollHeight;
													if(api.systemType == "android"){
														 //$api.setStorage("frame","paymethod");
														 $('html').addClass('noscroll');
													}else{
														 $("body").on("touchmove",function(event){
													 event.preventDefault;
													 }, false)
													}

													document.getElementById("bg").style.height = hh+"px";
													document.getElementById("bg").style.display="";
													api.openFrame({
															 name: 'zffs',
															 url: 'paymethod.html',
															 rect: {
																 x:0,
																 y:height*0.6,
																 w:width,
																 h:height*0.4
															 },
															 pageParam: {
																 taxcode:taxcode,
																 	rid:rid,
																	pay:pay,
																	 allspmc : allspmc,
																	 orderid : orderid,
																	dzObj : dzObj,
																	 bmc : "个人",
																	 seli : seli,
																	 amc : amc1,
																	 adh : adh1,
																	 adz : adz1,
																	bsh :"",
																bdzdh :"",
																	bkhh :"",
																bfplx :"Dz",
																 zje : total
															 }
													});
												}

	                     }else{
	                       api.alert({
	                           msg: ret.msg
	                       });
	                     }
	                  }else{
	                      api.alert({
	                       msg: "服务请求错误,请联系管理员"
	                      });
	                  }
	             }
	             var parameter = {"rid":rid,"amc":amc1,"adh":adh1,"adz":adz1,"taxcode":taxcode,"orderid":ganv(orderid),"dl_phone":jp};
	             apiAjax(JSON.stringify(parameter),url.svyj,callback);

				 }

    }

		function uPay(){
			var amc1 ="";// $("#sh_mc").val();
			var adh1 ="";// $("#sh_dh").val();
			var adz1 ="";// $("#sh_dz").val();

		 if(seli ==0){
					amc1 = $("#sh_mc").val();
					adh1 = $("#sh_dh").val();
					adz1 = $("#sh_dz").val();

					if(amc1 =="" || adh1 =="" || adz1 ==""){
						$("#loadingToast").hide();
						alert("请完善必填项！");
						return;
					}

				 if(amc1.length > 10){
					 $("#loadingToast").hide();
					 alert("收货人姓名过长！");
					 return;
				 }
				 if(adh1.length > 12){
					 $("#loadingToast").hide();
					 alert("联系电话过长！");
					 return;
				 }
				 if(adz1.length > 100){
					 $("#loadingToast").hide();
					 alert("详细地址过长！");
					 return;
				 }

				 adz1 = $("#address_sheng").find("option:selected").text() + $("#address_shi").find("option:selected").text() + "," + $("#address_qx").find("option:selected").text()  + "," + adz1;
				 //var num = $("#address_sheng").find("option:selected").text().indexOf("四川");
		 }else{
			 amc1 = dzObj[seli-1].mc;
			 adh1 = dzObj[seli-1].dh;
			 adz1 = dzObj[seli-1].dz;
		 }


				var width = document.documentElement.clientWidth;
				var height = document.documentElement.clientHeight;
				var hh = document.body.scrollHeight;
				if(api.systemType == "android"){
					 $api.setStorage("frame","paymethod");
					 $('html').addClass('noscroll');
				}else{
					 $("body").on("touchmove",function(event){
				 event.preventDefault;
				 }, false)
				}
				document.getElementById("bg").style.height = hh+"px";
				document.getElementById("bg").style.display="";
				$api.setStorage("frame","");
				$api.setStorage("upay","unionpay");

			 api.openFrame({
					 name: 'ylzff',
					 url: 'unionpay.html',
					 rect: {
						 x:0,
						 y:height*0.4,
						 w:width,
						 h:height*0.6
					 },
					 pageParam: {
							allspmc : allspmc,
							orderid : orderid,
							dzObj : dzObj,
							 bmc : "个人",
							seli : seli,
							 amc : amc1,
							 adh : adh1,
							 adz : adz1,
							 bsh :"",
						 bdzdh :"",
						 bkhh :"",
						 bfplx :"Dz",
						 zje : total,
						 pay : '1',
						 taxcode:taxcode,
						 rid : rid

					 }
				 });
		}

		function selectAddr(i){
   		$(".addr_checkbox").attr("checked", false);
   		$("#box" + i).attr("checked", true);
   		seli = i;
   	}

		function addr(_orderid){
        var callback = function(data, err){
            //console.log(JSON.stringify(ret));
        if(data.msg !=null){
	    		$("#pay_button").hide();
	    		$("#dzlist").html('');
	    		alert(data.msg);
	    	}else{
	    		if(data.addr != null){
		    		$("#sh_mc").val(data.addr.mc);
		    		$("#sh_dh").val(data.addr.dh);
		    		$("#sh_dz").val(data.addr.dz);
		    	}
	    		if(data.addrs != null && data.addrs.length > 0){
	    			dzObj = data.addrs;
	    			var html ="";
	    			for(var i=1;i<data.addrs.length + 1;i++){
	    				if(data.addrs[i-1].dz.indexOf(",") != -1){
		    				if(data.addrs[i-1].status == 0){
		    					seli = i;
		    					html +="<p>"
									+ " <b> 地址"+ i +" </b>："
									+ " <input type=\"checkbox\" checked id=\"box"+ i + "\" class=\"addr_checkbox\" onclick=\"selectAddr("+ i + ")\" tapmode=\"presshover\"/><br/>"
									+ " <label>收货人姓名 ：</label>" + data.addrs[i-1].mc + "<br/>"
									+ " <label>联系电话 ：</label>" + data.addrs[i-1].dh  + "<br/>"
									+ " <label>详细地址 ：</label>" + (data.addrs[i-1].dz).replace(new RegExp(',','gm'),'')
									+ " </p>";
		    				}else{
		    					html +="<p>"
									+ " <b> 地址"+ i +" </b>："
									+ " <input type=\"checkbox\" id=\"box"+ i + "\" class=\"addr_checkbox\" onclick=\"selectAddr("+ i + ")\" tapmode=\"presshover\"/><br/>"
									+ " <label>收货人姓名 ：</label>" + data.addrs[i-1].mc + "<br/>"
									+ " <label>联系电话 ：</label>" + data.addrs[i-1].dh  + "<br/>"
									+ " <label>详细地址 ：</label>" + (data.addrs[i-1].dz).replace(new RegExp(',','gm'),'')
									+ " </p>";
		    				}
	    				}
	    			}
	    			$("#dzlist").html(html);
	    		}else{
	    			$("#dzlist").html("");
	    			selectAddr(0);
	    		}

	    	}
	    }
	    var content = {"orderid":_orderid,"openid":_openid};
	    apiAjax(JSON.stringify(content),url.zcdzurl,callback);
   	}

    function funcGoto(){
	    if(api.systemType == "android"){
	        $('html').removeClass('noscroll');
	    }else{
	        $("body").off("touchmove");
	    }
	   document.getElementById("bg").style.display="none";
    }

  function funcGoto1(){
    if(api.systemType == "android"){
        $('html').removeClass('noscroll');
    }else{
        $("body").off("touchmove");
    }
   document.getElementById("bg").style.display="none";
   api.closeToWin({
   name: 'root'
     });
  }

  function show(){
   $("#loadingToast").show();
  }

  function hide(){
   $("#loadingToast").hide();
  }
</script>

</body></html>
